package com.cdwang.speakmodule;

import androidx.appcompat.app.AppCompatActivity;

import android.media.AudioManager;
import android.os.Bundle;
import android.speech.tts.TextToSpeech;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import com.cdwang.speaklib.SpeakUtils;

import java.util.Locale;

public class MainActivity extends AppCompatActivity{
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
//        textToSpeech = new TextToSpeech(this, this);
        SpeakUtils.INSTANCE.init(MainActivity.this);
        findViewById(R.id.tv).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
               SpeakUtils.INSTANCE.read("阅读理解111111111");
               SpeakUtils.INSTANCE.read("2222222222");
               SpeakUtils.INSTANCE.read("333333");
            }
        });
    }

    @Override
    protected void onStop() {
        super.onStop();
         SpeakUtils.INSTANCE.stop();
    }

    @Override
    protected void onDestroy() {
        SpeakUtils.INSTANCE.destory();
        super.onDestroy();
    }
    //    @Override
//    public void onInit(int status) {
//        if (status == TextToSpeech.SUCCESS){
//            int result = textToSpeech.setLanguage(Locale.CHINA);
//            if (result == TextToSpeech.LANG_MISSING_DATA || result == TextToSpeech.LANG_NOT_SUPPORTED){
//                Toast.makeText(this, "数据丢失或不支持", Toast.LENGTH_SHORT).show();
//            }
//        }else {
//            Log.e("错误代码",status+"");
//        }
//    }
}